/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nl.hanze.shoestring.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author alex
 */
@Entity
@Table(name = "reservering")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Reservering.findAll", query = "SELECT r FROM Reservering r"),
    @NamedQuery(name = "Reservering.findById", query = "SELECT r FROM Reservering r WHERE r.id = :id"),
    @NamedQuery(name = "Reservering.findByDatumBoeking", query = "SELECT r FROM Reservering r WHERE r.datumBoeking = :datumBoeking"),
    @NamedQuery(name = "Reservering.findByDatumAnnulering", query = "SELECT r FROM Reservering r WHERE r.datumAnnulering = :datumAnnulering"),
    @NamedQuery(name = "Reservering.findByBedrag", query = "SELECT r FROM Reservering r WHERE r.bedrag = :bedrag"),
    @NamedQuery(name = "Reservering.findByBetaald", query = "SELECT r FROM Reservering r WHERE r.betaald = :betaald")})
public class Reservering implements Serializable {
	@Basic(optional = false)
    @NotNull
    @Column(name = "datum_boeking")
    @Temporal(TemporalType.TIMESTAMP)
	private Date datumBoeking;
	@Column(name = "datum_annulering")
    @Temporal(TemporalType.TIMESTAMP)
	private Date datumAnnulering;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "bedrag")
    private Float bedrag;
    @Column(name = "betaald")
    private Boolean betaald;
    @JoinColumn(name = "planning_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Planning planningId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "reserveringId")
    private List<Deelnemer> deelnemerList;

    public Reservering() {
    }

    public Reservering(Integer id) {
        this.id = id;
    }

    public Reservering(Integer id, Date datumBoeking) {
        this.id = id;
        this.datumBoeking = datumBoeking;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getDatumBoeking() {
        return datumBoeking;
    }

    public void setDatumBoeking(Date datumBoeking) {
        this.datumBoeking = datumBoeking;
    }

    public Date getDatumAnnulering() {
        return datumAnnulering;
    }

    public void setDatumAnnulering(Date datumAnnulering) {
        this.datumAnnulering = datumAnnulering;
    }

    public Float getBedrag() {
        return bedrag;
    }

    public void setBedrag(Float bedrag) {
        this.bedrag = bedrag;
    }

    public Boolean getBetaald() {
        return betaald;
    }

    public void setBetaald(Boolean betaald) {
        this.betaald = betaald;
    }

    public Planning getPlanningId() {
        return planningId;
    }

    public void setPlanningId(Planning planningId) {
        this.planningId = planningId;
    }

    @XmlTransient
    public List<Deelnemer> getDeelnemerList() {
        return deelnemerList;
    }

    public void setDeelnemerList(List<Deelnemer> deelnemerList) {
        this.deelnemerList = deelnemerList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Reservering)) {
            return false;
        }
        Reservering other = (Reservering) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return getPlanningId().getReisId().getNaam();
    }
    
}
